package com.hualude.roadsign.controller;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.DTResponseDto;
import com.hualude.roadsign.dto.JsonMsgDto;
import com.hualude.roadsign.service.HighLeverFaultHandleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by xu_jiaHui on 2018/3/24.
 */
@Controller
@RequestMapping("/rds_highLeverFaultHandle")
public class HighLeverFaultHandleController {
    @Resource
    private HighLeverFaultHandleService highLeverFaultHandleService;

    @RequestMapping(value = "/getHighLeverFaultHandle4DT")
    @ResponseBody
    public DTResponseDto getHighLeverFaultHandle4DT(DTRequestDto dtRequestDto, String actorIds, Integer orgId, Integer highLeverMaintenanceStatus) {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = highLeverFaultHandleService.getHighLeverFaultHandle4DT(dtRequestDto, actorIds, orgId, highLeverMaintenanceStatus);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }

    @RequestMapping("/addHighLeverMaintenanceContent")
    @ResponseBody
    public JsonMsgDto addHighLeverMaintenanceContent(Integer highLeverFaultId, String highLeverMaintenanceContent) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(highLeverFaultHandleService.addHighLeverMaintenanceContent(highLeverFaultId, highLeverMaintenanceContent));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/finishHighLeverMaintenance")
    @ResponseBody
    public JsonMsgDto finishHighLeverMaintenance(String highLeverMaintenancePhoto, Integer highLeverMaintainerId, String highLeverMaintenanceTime, String highLeverMaintenanceExplain, Integer highLeverFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(highLeverFaultHandleService.finishHighLeverMaintenance(highLeverMaintenancePhoto, highLeverMaintainerId, highLeverMaintenanceTime, highLeverMaintenanceExplain, highLeverFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/getHighLeverFaultHandleList4App")
    @ResponseBody
    public JsonMsgDto getHighLeverFaultHandleList4App(Integer orgId, Integer highLeverMaintenanceStatus, String actorIds, Integer count, Integer size) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(highLeverFaultHandleService.getHighLeverFaultHandleList4App(orgId, highLeverMaintenanceStatus, actorIds, count, size));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/getHighLeverReceiptInfo4App")
    @ResponseBody
    public JsonMsgDto getHighLeverReceiptInfo4App(Integer highLeverFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(highLeverFaultHandleService.getHighLeverReceiptInfo4App(highLeverFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }
}
